<template>
	<view class="page">
		<!-- 头部搜索 -->
		<view class="header">
			<view class="searchBox">
				<u-icon name="search" style="font-size: 36rpx; color: #A8B5C5;"></u-icon>
				<u-input v-model="keywords" height="72" style="width: 540rpx; margin-left: 16rpx;"
					placeholder="请输入手机号" />
				<view class="search" @click="search()">
					搜索
				</view>
			</view>
		</view>
		<view class="tianchong"></view>
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="titleBox">
				<view class="txt">
					客户名称：{{ HOT(item.realname) || ''}}
				</view>
				<view class="king-flex">

					<view class="tag">
						创建时间：{{item.createDate || ''}}
					</view>
				</view>

			</view>
			<view class="list">
				<!-- 信息标题 -->
				<view class="left">
					电&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp话
				</view>
				<view class="right">
					<view class="centent">
						{{item.mobile || ''}}
					</view>
					<view class="xiangQing" @click="goShenQing(item)">
						指定电长 >
					</view>
				</view>
			</view>
			<view class="list">
				<!-- 信息标题 -->
				<view class="left">
					详情地址
				</view>
				<view class="right">
					<view class="centent">
						{{item.address}}
					</view>
				</view>
			</view>
			<view class="list">
				<!-- 信息标题 -->
				<view class="left">
					公司名称
				</view>
				<view class="right">
					<view class="centent">
						{{item.companyName || ''}}
					</view>
				</view>
			</view>

			<view class="list">
				<!-- 信息标题 -->
				<view class="left">
					修改时间
				</view>
				<view class="right">
					<view class="centent">
						{{item.updateDate ||''}}
					</view>
				</view>
			</view>

		</view>
		<!-- 加载更多 -->
		<u-loadmore v-if="list.length !== 0" :status="status" :load-text="loadText" />
		<image v-else src="@/static/image/empty.png" mode="widthFix" class="is-empty"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				provinceId: null,
				keywords: '',
				page: 1,
				limit: 10,
				more: false,
				// 页面数据初始化状态
				loadText: {
					loadmore: '轻轻上拉，加载更多',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				list: [],
				statusTextArr: [
					'已签约',
					'意向签约',
					'待跟进',
					'暂不考虑',
					'待线上联系',
					'待分配客户',
					'无效客户'
				],
			}
		},
		mounted() {
			uni.$on('reloadData', (res) => {
				this.page = 1
				this.getCustomRes()
			})
		},
		created() {
			this.getgetTownerRes()
			this.getUser()
		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.getgetTownerRes()
		},
		//上拉加载
		onReachBottom() {
			if (this.page == 1) {
				return
			}
			if (this.more) {
				this.getCourseRes()
			}
		},
		methods: {

			search() {
				this.page = 1
				this.getgetTownerRes()
			},
			getgetTownerRes() {
				var params = {
					limit: this.limit,
					page: this.page,
					orderField: 'id',
					order: 'desc',
				}
				if (this.keywords) {
					params.mobile = this.keywords
				}
				this.$axios.request(this.$api.getUserResApi, "GET", params).then((val) => {
					uni.stopPullDownRefresh();
					this.list = this.page == 1 ? val.data.list : this.list.concat(val.data.list)
					if (Math.ceil(val.data.total / this.limit) > this.page) {
						this.more = true;
						this.page++
					} else {
						this.more = false;
					}
				})
			},
			// 获取省份Id
			getUser() {
				this.$axios.request(this.$api.getUser, "GET").then((val) => {
					this.provinceId = val.data.provinceId
				})
			},
			// 去申请
			goShenQing(items) {
				this.$store.commit("setShowuSerId", items.id)
				if (this.provinceId == 0) {
					uni.navigateTo({
						url: `/pages/mine/select_sheng`
					})
				} else {
					uni.navigateTo({
						url: `./suoZaiShi?provinceId=${this.provinceId}`
					})
				}
			
			},
			// 超过6个字打点显示
			HOT(val) {

				let splitAdd3 = val.split("");
				let txt = ''
				if (splitAdd3.length > 7) {
					txt = val.slice(0, 7) + '...';
				} else {
					txt = val
				}
				return txt

			}
		}
	}
</script>

<style>
	.page {
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		background-color: #f9f9f9;
	}

	.header {
		position: fixed;
		left: 0;
		top: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 120rpx;
		background-color: #FFFFFF;

	}

	.tianchong {
		width: 100%;
		margin-top: 136rpx;
	}

	.searchBox {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 702rpx;
		height: 72rpx;
		/* margin: 16rpx auto 16rpx; */
		background-color: #f0f0f0;
		/* background-color: red; */
	}

	.search {
		width: 90rpx;
		height: 40rpx;
		font-size: 32rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		line-height: 40rpx;
		color: #3975EA;
		border-left: 2rpx solid #A8B5C5;
		text-align: center;
		opacity: 1;
	}

	.item {
		overflow: hidden;
		width: 100%;
		/* height: 311rpx; */
		background-color: #fff;
		margin: 16rpx 0rpx;
		padding: 16rpx 0rpx;
		/* padding-left: 32rpx; */
	}

	.titleBox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		/* width: 750rpx; */
		height: 42rpx;
		margin-top: 16rpx;
		margin: 0rpx 32rpx;
	}

	.txt {
		height: 40rpx;
		font-size: 32rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 40rpx;
		color: #333333;
	}

	.tag {
		/* width: 128rpx; */
		height: 40rpx;
		margin-left: 10rpx;
		font-size: 20rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 40rpx;
		color: #F5F5F5;
		/* text-align: center; */
		padding: 0 15rpx;
		background-color: #3975EA;
	}

	.biaoHao {
		height: 28rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 20rpx;
		color: #BBBBBB;
		margin: 15rpx 0 18rpx;
		margin-left: 32rpx;
	}

	.list {
		display: flex;
		border-bottom: 2px solid #f9f9f9;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 65rpx;
	}

	.list:last-child {
		border-bottom: none;
	}

	.left {
		width: 188rpx;
		height: 33rpx;
		font-size: 28rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 33rpx;
		color: #333333;
		margin-left: 32rpx;
	}

	.right {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 590rpx;
		height: 33rpx;
	}

	.centent {
		font-size: 28rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		color: #BBBBBB;
	}

	.xiangQing {
		/* width: 71rpx; */
		height: 33rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		line-height: 33rpx;
		color: #FF5D58;
		margin-right: 32rpx;
	}

	.item .list:first-child {
		border-top: 4rpx solid #F3F4F8;
	}

	.add {
		position: fixed;
		right: 36rpx;
		bottom: 102rpx;
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		font-size: 60rpx;
		line-height: 77rpx;
		text-align: center;
		color: #FFFFFF;
		background-color: #2E6ADF;
	}

	.compelet {
		position: fixed;
		bottom: 0;
		left: 32rpx;
		width: 686rpx;
		height: 80rpx;
		background-color: #2E6ADF;
		opacity: 1;
		border-radius: 4rpx;
		font-size: 32rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 80rpx;
		margin: 0 auto 0;
		text-align: center;
		color: #FFFFFF;
		opacity: 1;
	}
</style>
